import { History } from '@site/src/components/History';

# 🗄️ List Files

Returns all files in a directory (independent of their depth) or the file itself.

<History
  records={[
    {
      version: '2.5.0',
      changes: [
        <>
          <strong>CLI:</strong> deprecate <code>--list-files</code> in order to{' '}
          <code>--listFiles</code>.
        </>,
      ],
    },
    {
      version: '2.4.0',
      changes: [<>Support for CLI usage.</>],
    },
  ]}
/>

## CLI

Displays all the files returned in the terminal, without running the tests.

```sh
npx poku --listFiles
```

```sh
npx poku ./test --listFiles
```

```sh
npx poku ./packages/**/test --listFiles
```

```sh
npx poku ./test/unit ./test/e2e --listFiles
```

- You can use the `--filter` and `--exclude` flags and include multiple paths.

:::note

The files returned by `--listFiles` don't reflect the paths displayed by `--debug`:

- **`--debug`:** the paths to be searched for.
- **`--listFiles`:** the paths found.

:::

:::tip
If you pass flags apart from `--filter` and `--exclude`, they will be ignored.
:::

## API

> `listFiles(targetDir: string, configs?: ListFilesConfigs)`

```ts
import { listFiles } from 'poku';

await listFiles('some-dir');
```

- You can use the `filter` and `exclude` options, as well as they are for **`poku`** method.

:::info

To compile tests using `listFiles` with **TypeScript**, you may will need to install **@types/node**:

```bash
npm i -D @types/node
```

:::
